package cn.topcodes.tcsf.admin.commons.api.convertor;

import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.converter.HttpMessageNotReadableException;

import java.io.IOException;
import java.lang.reflect.Type;

/**
 * Created by Unicorn on 2018/6/14.
 */
public class JsonHttpMessageConverter extends FastJsonHttpMessageConverter {

    @Override
    public Object read(Type type, Class<?> contextClass, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
        try {
            return super.read(type, contextClass, inputMessage);
        }catch (Exception e) {
            throw new IllegalArgumentException("JSON参数无法解析");
        }
    }
}
